# -*- coding: utf-8 -*-
'''
@文件    :logger.py
@说明    :日志处理器
@时间    :2025/08/10 03:54:58
@作者    :浪晋
@版本    :1.0
'''
from app.core.plugin import logger
from app.core.plugin import ctx


def x_requests_id(record):
    record['extra']['x_requests_id'] = f"{ctx.get('stack') or '918e3662-85ed-42bc-8ca4-be1b172552dd'}"
    return record


async def init_logger_config():
    logger.add(patcher=x_requests_id)
    logger.info("初始化日志完成...")


async def close_logger_config():
    logger.info("关闭日志完成...")
    logger.remove()